<?php
/**
 * Created by PhpStorm.
 * User: wangkxin@foxmail.com
 * Date: 2022/4/11
 * Time: 0:11
 */

namespace app\index\controller;


use app\Request;

class Index
{
    public function index(Request $request)
    {

        return 'index';
    }

    public function testPay()
    {
        // 网页兼扫码支付
        $payO = new PayController();
        $re = $payO->web();

        //扫码支付
        // $re = $payO->scan();
        // var_dump($re);

        //转账
        // $re = $payO->transfer();
        return  $re;
        // return json(['code'=>200,'data'=>$re]);
    }


    /**
     * ab 压力测试带post,header头 参数
     */
    public function abTest(Request $request)
    {
        $fileName = __DIR__ .'/cert/abtest.txt';
        $tmpArr = array();

        $name = $request->post('name');
        $password = $request->post('password');
        $token = $request->header('token');


        if($name && $password){
            $tmpArr = $request->pathinfo();

            $jsonStr = json_encode($tmpArr);
            $newLog ='log_time:'.date('Y-m-d H:i:s ').$jsonStr." {$name} -- {$password} -- {$token} ";
            file_put_contents($fileName,$newLog.PHP_EOL,FILE_APPEND);
            return 'ab测试';
        }
    }





}